searchbar: Properly remove child widgets
authorTimm Bäder <mail@baedert.org>
Sun, 4 Feb 2018 16:51:18 +0000 (17:51 +0100)
committerTimm Bäder <mail@baedert.org>
Sun, 4 Feb 2018 16:51:18 +0000 (17:51 +0100)
Since the GtkSearchBar is not the direct parent, we need to remove them
properly from priv->box_center.

gtk/gtksearchbar.c

index 316abc33ec525d7d7e65ef02324ba90341df5e0f..acd85995c9c3c58edefd7282e73e67d2b34a01ff 100644 (file)
@@ -320,6 +320,23 @@ gtk_search_bar_add (GtkContainer *container,
     }
 }
 
+static void
+gtk_search_bar_remove (GtkContainer *container,
+                       GtkWidget    *child)
+{
+  GtkSearchBar *bar = GTK_SEARCH_BAR (container);
+  GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
+
+  if (priv->box_center == NULL)
+    {
+      GTK_CONTAINER_CLASS (gtk_search_bar_parent_class)->remove (container, child);
+    }
+  else
+    {
+      gtk_container_remove (GTK_CONTAINER (priv->box_center), child);
+    }
+}
+
 static void
 gtk_search_bar_set_property (GObject      *object,
                              guint         prop_id,
@@ -390,6 +407,7 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass)
   object_class->get_property = gtk_search_bar_get_property;
 
   container_class->add = gtk_search_bar_add;
+  container_class->remove = gtk_search_bar_remove;
 
   /**
    * GtkSearchBar:search-mode-enabled: